<?php

namespace app\api\controller;

use app\common\controller\Api;

/**
 * 首页接口.
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页.
     */
    public function index()
    {
        $this->success('请求成功');
    }
    
    public function ali(){
        
            $app_id    = '2021001144613411';
            $sign_type = 'RSA'; // RSA  RSA2
        
            // 支付宝公钥字符串
            $ali_public_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmfW7vg4fJTMeOHj3wHxSMqte662SYMy5Nrdx2N/QhcUaGxWWkeAlF/GshSN65mVcf7rM5SXo1XHDHzEwTEbRuQgprGncp+ZKCuLyegv8oVhmLX7gdlU3wx922GyNftv1gvRnWiVFOLIPS5yO8mc6N1niC874kO3mZyWTrO4h8OO1zmujWyv8uecVLO5niThiN2PX1K3WY7xt8VKGiuVHBrVg9OAyBacraKVYRY8Yz1BfaIgw8vzwhnyFyMwMBOoaYomPw1PSaVPX3hE68znRHUNhJarAS7jH682lVU/uOXjLfKB3FkK4O3Lew0gWgLoLgoHc1AUAxoY+bAyXOKyx/wIDAQAB';
        
            // 自己生成的密钥字符串
            $rsa_private_key = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCI4rZFstZqhlSujSt93Il62PyeKIgGhfciz+ia0G5RImZWWueCmQkkAxC/qEesWKm/aRfBxT97Ympdhlg4qwPRZSCqAkCMN7foTbefNeTny7Kc1QM8M7DxDavYzvCEjsrWriBT8HBtlT7IYzXbpsd+7VLq4V4TN40KVTouMPDsf211tnXotKbGKgnbVSqiiGBsxjpMFxlARUK9uV8vE8dotWUhJZmxc3LzsoXmfix6PbDubF7J05j6qxgvkoT8HG9fpRmnDg8kFFO2RKSdpZF0IpVC6lLOjFZZmn+x1RG6ohIvE7Iu8DVV+R9fiPW+ByGriuQ3luP7IEXqJSzNwnedAgMBAAECggEAFvX4Xw6Ver7Xm4PghLcmdG3LSfhAgN+dycAYI0fNCVz8z4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MM8vndH7HATTwNhPrO2LKl8vLWD6OS2Bs1gxtiCXFvZ4uLjBLLWtvlVZGQV3Y05AB6KUW/bxdHq3Q9PGhYoqyZ2+SU=';
        
            // 与业务相关参数
            $notify_url = 'http://39.101.192.177/api/index/notifyurl';
            $return_url = 'http://39.101.192.177/index/index/filish';
        // ];
        $params = new \Yurun\PaySDK\Alipay\Params\PublicParams;
        $params->appID = $app_id;
        $params->sign_type = $sign_type;
        $params->appPrivateKey = $rsa_private_key;
        $params->appPublicKey = $ali_public_key;
        $params->md5Key = 'xxx';
        $pay = new \Yurun\PaySDK\AlipayApp\SDK($params);
        $request = new \Yurun\PaySDK\AlipayApp\Wap\Params\Pay\Request;
        $request->notify_url = $notify_url; // 支付后通知地址（作为支付成功回调，这个可靠）
        $request->return_url = $return_url; // 支付后跳转返回地址
        $request->businessParams->seller_id = $app_id; // 卖家支付宝用
        $request->businessParams->out_trade_no = 'test' . mt_rand(10000000,99999999); // 商户订单号
        $request->businessParams->total_fee  = 0.01; // 价格
        $request->businessParams->show_url = 'http://www.yurunsoft.com';
        $request->businessParams->subject = '小米手机9黑色陶瓷尊享版'; // 商品标题
// 跳转到支付页面
// $pay->redirectExecute($request);
// 获取跳转url
        $pay->prepareExecute($request, $url);
        var_dump($url);
    }
    public function notifyurl(){
        
    }
}
